package graphics;

public enum TileShape {
	//junctions
	CROSS,
	LRD,
	LUD, 
	LRU,
	RUD,
	//corners
	LD,
	LU,
	RD,
	RU,
	//straight paths
	UD,
	LR,
	//dead-ends
	U,
	D,
	L,
	R,
	BLANK;
		
	/**
	 * Returns a {@link TileShape} depending on the logical properties of the corresponding node.
	 * @param up {@link Boolean} if a path in that direction exists.
	 * @param down {@link Boolean} if a path in that direction exists.
	 * @param left {@link Boolean} if a path in that direction exists.
	 * @param right {@link Boolean} if a path in that direction exists.
	 * @return {@link TileShape} representing the tile's possible movement directions.
	 */
	static TileShape getType(boolean up, boolean down, boolean left, boolean right){
		if(!up && !down && !left && !right){
			return BLANK;
		}
		if(up){						//set including {up}
			if(down){				//set including {up, down}
				if(left && right){
					return CROSS;
				}
				else if(left){
					return LUD;
				}
				else if(right){
					return RUD;
				}
				else{
					return UD;
				}
			}
			else if(left){			//set including {up}, excluding {down}
				if(right){
					return LRU;
				}
				else{
					return LU;
				}				
			}
			else if(right){			
				return RU;
			}
			else{
				return U;
			}
		}
		else{						//sets excluding {up}
			if(down){				//sets excluding {up}, including {down}
				if(left && right){
					return LRD;
				}
				else if(left){
					return LD;
				}
				else if(right){
					return RD;
				}
				else{
					return D;
				}
			}
			else{					//sets excluding {up, down}
				if(left && right){
					return LR;
				}
				else if(left){
					return L;
				}
				else{
					return R;
				}
			}
		}
	}
}
